package com.yutong.redis.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.redis.core.script.DefaultRedisScript;
import org.springframework.scripting.support.ResourceScriptSource;

/**
 * @author zhangbinbin
 * @version 1.0
 * @date 2022/1/29
 */
@Configuration
public class BidAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public DefaultRedisScript<Long> bidDefaultRedisScript() {
        DefaultRedisScript<Long> defaultRedisScript = new DefaultRedisScript<>();
        defaultRedisScript.setResultType(Long.class);
        defaultRedisScript.setScriptSource(new ResourceScriptSource(new ClassPathResource("script/nextuuid.lua")));
        return defaultRedisScript;
    }
}